/**
 * Created by Administrator on 2018-07-03.
 */

/**
 * 库存管理中的入库记录
 * Created by Administrator on 2018/4/28.
 */

define(function (require,exports,module) {
    var sTpl = require("./stockInRecord.html");

    var VueComponent = Vue.extend({
        template: sTpl
        ,methods:{
            pickTime2:function (val) {
                this.checkFormInline.stockDate= val;
            },
            findAllStockInRecord:function() {
                var $this = this;
                axios.post(basepath+"/api/inventoryManagement/findAllStockInRecord"
                ).then(function (response) {
                    $this.tableData=response.data;
                });
            },
            checkStockInRecord:function () {
                var $this = this;
                axios.get(basepath+"/api/inventoryManagement/checkStockInRecord",{
                    params: {
                        goodsCategory:$this.checkFormInline.goodsCategory,
                        goodsCode:$this.checkFormInline.goodsCode,
                        stockDate:$this.checkFormInline.stockDate,
                        supplier:$this.checkFormInline.supplier
                    }}
                ).then(function (response) {
                    console.log(response);
                    $this.tableData=response.data;
                });
            }

        },
        mounted:function() {

        }
        ,data:function(){
            return {
                title:'',
                dialogFormVisible: false,
                checkFormInline: {
                    goodsCategory:'',
                    goodsCode:'',
                    stockDate:'',
                    supplier:''
                },
                pickerOptions1: {
                    shortcuts: [{
                        text: '今天',
                        onClick:function(picker) {
                            picker.$emit('pick', new Date());
                        }
                    }, {
                        text: '昨天',
                        onClick:function(picker) {
                            const date = new Date();
                            date.setTime(date.getTime() - 3600 * 1000 * 24);
                            picker.$emit('pick', date);
                        }
                    }, {
                        text: '一周前',
                        onClick:function (picker) {
                            const date = new Date();
                            date.setTime(date.getTime() - 3600 * 1000 * 24 * 7);
                            picker.$emit('pick', date);
                        }
                    }]
                },
                pickerOptions2: {
                    shortcuts: [{
                        text: '今天',
                        onClick:function(picker) {
                            picker.$emit('pick', new Date());
                        }
                    }, {
                        text: '昨天',
                        onClick:function(picker) {
                            const date = new Date();
                            date.setTime(date.getTime() - 3600 * 1000 * 24);
                            picker.$emit('pick', date);
                        }
                    }, {
                        text: '一周前',
                        onClick:function (picker) {
                            const date = new Date();
                            date.setTime(date.getTime() - 3600 * 1000 * 24 * 7);
                            picker.$emit('pick', date);
                        }
                    }]
                },
                tableData: {}
            }
        },
        created:function (){
            this.findAllStockInRecord();

            // this.urls.url = basepath+"api/appointment/findAppointment";
        },
        activated:function () {
            messages.$emit('change','入库记录');
        }
    });
    module.exports = VueComponent;
})

